<!DOCTYPE html>
<html lang="zh_CN">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

</body>
<script type="text/javascript">
    var a = [1, 2, 3];
    var b = [];
    /*var b = a; // 对象的拷贝都是 浅拷贝，地址拷贝
    b.push(4);
    console.log('b的值', b);
    console.log('a的值', a);*/

    function extend(target, original) {

        for (var i = 0; i < original.length; i++) {
            target[i] = original[i];

        }

        return target;
    }


    var newB = extend(b, a);
    newB.push(4);
    console.log(newB, a);
</script>

</html>
